package com.example.demo.services.imp;

import com.example.demo.entity.article;
import com.example.demo.mapper.articleMapper;
import com.example.demo.services.articleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class articleServiceImp implements articleService {

    @Autowired
    private articleMapper articleMapper;

    @Override
    public List<article> selectall() {
        return articleMapper.selectall();
    }

    @Override
    public Integer addArticle(String name, String title, String content, String userName, String userId, LocalDateTime dateTime, String img) {
        return articleMapper.addArticle(name, title, content, userName, userId, dateTime, img);
    }

    @Override
    public Integer updateArticle(String content, Integer id) {
        return articleMapper.updateArticle(content, id);
    }

    @Override
    public article selectId(Integer id) {
        return articleMapper.selectUser(id);
    }

    @Override
    public PageInfo<article> selectname(String name,Integer num) {
        PageHelper.startPage(num,12);
        List<article> list=articleMapper.selectname(name);
        PageInfo<article> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
}
